﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;

namespace Dingding.Helper
{
    public class HttpHelper
    {
        //以GET方式抓取远程页面内容
        public static string GetHtml(string tUrl)
        {
            string strResult;
            try
            {
                HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(tUrl);
                hwr.Timeout = 19600;
                HttpWebResponse hwrs = (HttpWebResponse)hwr.GetResponse();
                Stream myStream = hwrs.GetResponseStream();
                StreamReader sr = new StreamReader(myStream, Encoding.UTF8);
                //StringBuilder sb = new StringBuilder();
                strResult = sr.ReadToEnd();
                //while (-1 != sr.Peek())
                //{
                //    sb.Append(sr.ReadLine() + "\r\n");
                //}
                //strResult = sb.ToString();
                hwrs.Close();
            }
            catch (Exception ee)
            {
                strResult = ee.Message;
            }
            return strResult;
        }
    }
}